import pandas as pd

def main():
    # 读取数据文件
    with open("./error_file/data.txt", "r", encoding="utf-8") as file:
        lines = file.readlines()

    # 处理数据
    data = []
    for line in lines:
        line = line.strip()  # 去除每行首尾的空白字符
        items = line.split(" ")  # 按空格分割每行文本
        country = items[0]
        stance = items[1]
        content = " ".join(items[2:])  # 将剩余部分合并为内容
        data.append([country, stance, content])

    # 创建 DataFrame
    df = pd.DataFrame(data, columns=["国家/地区", "立场", "内容"])

    # 保存 DataFrame 到 Excel 文件
    df.to_excel("./error_file/test_data.xlsx", index=False)
if __name__ == '__main__':
    main()
